package com.fy.fyzf.dialog;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import com.example.zhouwei.library.CustomPopWindow;
import com.fy.fyzf.R;

public class CityDetailFilterPopwindow {

    private Context mContext;
    View popView;
    public CityDetailFilterPopwindow(Context context) {
        mContext = context;
        popView = LayoutInflater.from(mContext).inflate(R.layout.popwindow_area_filter, null, false);
        initView();
    }

    //省市区id
    private int provinceId;
    private int cityId;
    private int areaId;

    RecyclerView recyclerView1;
    RecyclerView recyclerView2;
    RecyclerView recyclerView3;
//    RecyclerView recyclerView4;
//    RecyclerView recyclerView5;
    private void initView() {
         recyclerView1 = popView.findViewById(R.id.recycleView1);

         recyclerView2 = popView.findViewById(R.id.recycleView2);
         recyclerView3 = popView.findViewById(R.id.recycleView3);
//         recyclerView4 = popView.findViewById(R.id.recycleView4);
//         recyclerView5 = popView.findViewById(R.id.recycleView5);

    }

    /**
     * 返回不同的recycleView
     * @param i
     * @return
     */
    public RecyclerView getCurrentView(int i){
        if (i == 1) {
            return recyclerView1;
        } else if (i == 2) {
            return recyclerView2;
        }else  {
            return recyclerView3;
        }/* else if (i == 4) {
            return recyclerView4;
        } else {
            return recyclerView5;
        }*/

    }

    CustomPopWindow customPopWindow;
    public CustomPopWindow getPopWindow(){
        return customPopWindow;
    }
    public CityDetailFilterPopwindow showPop(View view){
        customPopWindow= new CustomPopWindow.PopupWindowBuilder(mContext).setView(popView)
                .size(ViewGroup.LayoutParams.MATCH_PARENT, 1000)
                .setFocusable(true)
                .setOutsideTouchable(false)
                .enableBackgroundDark(true)
                .create()//创建PopupWindow
                .showAsDropDown(view,0,-10);

        popView.findViewById(R.id.ll_unuseable).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                customPopWindow.dissmiss();
            }
        });

        /*popView.findViewById(R.id.tv_default).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                customPopWindow.dissmiss();
            }
        });*/
        return this;
    }

    public View getView(int viewId){
        return popView.findViewById(viewId);
    }
}
